﻿using Confluent.Kafka;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Microsoft.Extensions.DependencyInjection
{
    public static class KafkaClientExtensions
    {
        public static IServiceCollection AddKafkaClient(this IServiceCollection services, IConfiguration configuration)
        {

            services.AddSingleton<ProducerConfig>(provider =>
            {
                return new ProducerConfig
                {
                    BootstrapServers = configuration["Kafka"]  //Kafka集群地址
                };
            });

            return services;
        }
    }
}
